﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Vds2465Telegrams
{
	public enum eBusType
	{
		/// <summary>
		/// 0x01
		/// </summary>
		EIBus = 0x01,

		/// <summary>
		/// 0x02
		/// </summary>
		M_Bus = 0x02
	}

	public class UserData_74_Container : UserData_Device_Bytes
	{
		#region private member variables

		private readonly byte _busType;

		#endregion private member variables

		#region constructor

		/// <summary>
		/// 
		/// </summary>
		/// <param name="device"></param>
		/// <param name="busType">byte type and not enum because spec says that more bus types are allowed</param>
		/// <param name="bytes"></param>
		public UserData_74_Container(byte device, byte busType, byte[] bytes)
			: base(UserData.UserData74Container, device, bytes)
		{
			_busType = busType;
		}

		#endregion constructor

		#region getters

		public byte BusType { get { return _busType; } }

		#endregion getters

		#region ToString, Equals, GetHashCode

		public override int GetHashCode()
		{
			int hashCode = base.GetHashCode();
			hashCode ^= _busType;
			return hashCode;
		}

		public override string ToString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("(");
			stringBuilder.Append(ToStringProperties());
			stringBuilder.Append(")");

			return stringBuilder.ToString();
		}

		internal override string ToStringProperties()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append(base.ToStringProperties());

			stringBuilder.Append(", ");

			stringBuilder.Append("BusType='");
			stringBuilder.Append(BusType);
			stringBuilder.Append("'");

			return stringBuilder.ToString();
		}

		public override bool Equals(object obj)
		{
			Type objType = obj.GetType();
			if (this.GetType() == objType)
			{
				UserData_74_Container userData2Compare = obj as UserData_74_Container;
				return EqualsProperties(userData2Compare);
			}

			return false;
		}

		internal bool EqualsProperties(UserData_74_Container userData2Compare)
		{
			if (base.EqualsProperties(userData2Compare))
			{
				return (BusType == userData2Compare.BusType);
			}

			return false;
		}		

		#endregion ToString, Equals, GetHashCode
	}
}
